<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      // 21.   用户输入一个整数n，计算n的阶乘。即n*(n-1)*(n-2)*……*3*2*1.
        var n = parseInt(prompt("请输入一个正整数"));
        var mul = 1;
        for (var i = n; i >= 1; i--) {
          mul *= i;
        }
        // 循环结束后使用累乘结果
        console.log(mul);
    </script>
  </head>
  <body></body>
</html>
